package utils;

public class CUtil {
	
	public static int CoModule(int num, int div)
	{
		int i=1;
		while(i<div)
		{
			if((i*num)%div == 1)
				return i;
			i++;
		}
		return -1;
	}	
	
	public static int[] TextToNumbers(String str)
	{
		char[] arg=str.toUpperCase().toCharArray();
		int[] rez=new int[arg.length];
		int i=0;
		while (i< rez.length)
		 {
			switch(arg[i])
		 	 {
		 	 	case('A'): rez[i]=0;
		 	 	break;
		 	 	case('B'): rez[i]=1;
		 	 	break;
		 	 	case('C'): rez[i]=2;
		 	 	break;
		 	 	case('D'): rez[i]=3;
		 	 	break;
		 	 	case('E'): rez[i]=4;
		 	 	break;
		 	 	case('F'): rez[i]=5;
		 	 	break;
		 	 	case('G'): rez[i]=6;
		 	 	break;
		 	 	case('H'): rez[i]=7;
		 	 	break;
		 	 	case('I'): rez[i]=8;
		 	 	break;
		 	 	case('J'): rez[i]=9;
		 	 	break;
		 	 	case('K'): rez[i]=10;
		 	 	break;
		 	 	case('L'): rez[i]=11;
		 	 	break;
		 	 	case('M'): rez[i]=12;
		 	 	break;
		 	 	case('N'): rez[i]=13;
		 	 	break;
		 	 	case('O'): rez[i]=14;
		 	 	break;
		 	 	case('P'): rez[i]=15;
		 	 	break;
		 	 	case('Q'): rez[i]=16;
		 	 	break;
		 	 	case('R'): rez[i]=17;
		 	 	break;
		 	 	case('S'): rez[i]=18;
		 	 	break;
		 	 	case('T'): rez[i]=19;
		 	 	break;
		 	 	case('U'): rez[i]=20;
		 	 	break;
		 	 	case('V'): rez[i]=21;
		 	 	break;
		 	 	case('W'): rez[i]=22;
		 	 	break;
		 	 	case('X'): rez[i]=23;
		 	 	break;
		 	 	case('Y'): rez[i]=24;
		 	 	break;
		 	 	case('Z'): rez[i]=25;
		 	 	break;
		 	 }
			i++;
		 }
		
		return rez;
	}
	
	
	public static String NumbersToText(int[] arg)
	{
		char[] rez=new char[arg.length];
		int i=0;
		while (i< rez.length)
		 {
			switch(arg[i])
		 	 {
		 	 	case(0): rez[i]='A';
		 	 	break;
		 	 	case(1): rez[i]='B';
		 	 	break;
		 	 	case(2): rez[i]='C';
		 	 	break;
		 	 	case(3): rez[i]='D';
		 	 	break;
		 	 	case(4): rez[i]='E';
		 	 	break;
		 	 	case(5): rez[i]='F';
		 	 	break;
		 	 	case(6): rez[i]='G';
		 	 	break;
		 	 	case(7): rez[i]='H';
		 	 	break;
		 	 	case(8): rez[i]='I';
		 	 	break;
		 	 	case(9): rez[i]='J';
		 	 	break;
		 	 	case(10): rez[i]='K';
		 	 	break;
		 	 	case(11): rez[i]='L';
		 	 	break;
		 	 	case(12): rez[i]='M';
		 	 	break;
		 	 	case(13): rez[i]='N';
		 	 	break;
		 	 	case(14): rez[i]='O';
		 	 	break;
		 	 	case(15): rez[i]='P';
		 	 	break;
		 	 	case(16): rez[i]='Q';
		 	 	break;
		 	 	case(17): rez[i]='R';
		 	 	break;
		 	 	case(18): rez[i]='S';
		 	 	break;
		 	 	case(19): rez[i]='T';
		 	 	break;
		 	 	case(20): rez[i]='U';
		 	 	break;
		 	 	case(21): rez[i]='V';
		 	 	break;
		 	 	case(22): rez[i]='W';
		 	 	break;
		 	 	case(23): rez[i]='X';
		 	 	break;
		 	 	case(24): rez[i]='Y';
		 	 	break;
		 	 	case(25): rez[i]='Z';
		 	 	break;
		 	 }
			i++;
		 }
		
		return new String(rez);
	}
}
